<%--                                                                       --%>
<%-- Copyright (c) 2004 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<% String ctxPath = request.getContextPath(); %>
<c:set var="editImg">
<img src="<%= ctxPath %>/ep/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>">
</c:set>
<c:set var="deleteImg">
<img src="<%= ctxPath %>/ep/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>">
</c:set>
<c:set var="viewImg">
<img src="<%= ctxPath %>/ep/images/action/icon_view.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.view" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.view" bundle="ep.messages"/>">
</c:set>


<script language="JavaScript">

  function doMicrositeTemplateEditAction(msId, instCount) {
    document.epMicrositeTemplateListForm.micrositeTemplateId.value = msId;
    document.epMicrositeTemplateListForm.instanceCount.value = instCount;
    document.epMicrositeTemplateListForm.action = '<c:url value="/ep/micrositeTemplateEdit.do"/>';
    document.epMicrositeTemplateListForm.submit();
  }

  function doMicrositeTemplateDeleteAction(msId) {
    if(confirm('<bean-el:message key="ep.microsite.delete.confirm" bundle="ep.messages"/>' )){
      document.epMicrositeTemplateListForm.micrositeTemplateId.value = msId;
      document.epMicrositeTemplateListForm.listSessionAttribute.value = 'MicrositeTemplateListResult';
      document.epMicrositeTemplateListForm.action = '<c:url value="/ep/micrositeTemplateDelete.do"/>';
      document.epMicrositeTemplateListForm.submit();
      return;
    }
    else return false;
  }

  function doMicrositeTemplateViewAction(msId, instCount) { 
    document.epMicrositeTemplateListForm.micrositeTemplateId.value = msId;
    document.epMicrositeTemplateListForm.instanceCount.value = instCount;
    document.epMicrositeTemplateListForm.action = '<c:url value="/ep/micrositeTemplateView.do"/>';
    document.epMicrositeTemplateListForm.submit();
  }

  function doMSTemplateNewAction(){
    document.epMicrositeTemplateListForm.listSessionAttribute.value = 'MicrositeTemplateListResult';
    document.epMicrositeTemplateListForm.action = '<c:url value="/ep/micrositeTemplateNew.do"/>';
    document.epMicrositeTemplateListForm.submit();
  }
</script>

<html-el:form action="/ep/micrositeTemplateList.do">
<input type="hidden" name="micrositeTemplateId"/>
<input type="hidden" name="instanceCount"/>
<input type="hidden" name="listSessionAttribute"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
      <bean-el:message key="ep.microsite.templates.manage.page.title" bundle="ep.messages"/>
      </div>
      <div class="errorMessage"><html-el:errors/></div>
      <%@include file="/mc/common/pagetab.jsp" %>

      <div class="pageSubtitle">
        <span class="left"><bean-el:message key="ep.microsite.templates" bundle="ep.messages"/></span>
        <span class="right">
          <input type="button" class="titleButton" value='<bean-el:message key="button.new.microsite.template" bundle="ep.messages"/>'
            onclick="doMSTemplateNewAction();"/>
        </span>
      </div>
      
      <!-- header -->
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
          <th id="Name" align="left"><bean-el:message key="ep.header.microsite.template.name" bundle="ep.messages"/></th>
          <th id="Description" align="left"><bean-el:message key="ep.header.microsite.template.description" bundle="ep.messages"/></th>
          <th id="InstanceCount" align="left"><bean-el:message key="ep.header.microsite.template.instance" bundle="ep.messages"/></th>
          <th id="Actions" align="left" nowrap><bean-el:message key="ep.header.actions" bundle="ep.messages"/></th>
        </tr>

        <!-- results -->
        <c:choose>
        <c:when test="${not empty list}">
          <c:forEach var="item" items="${list}" varStatus="index">        
            <c:choose>
              <c:when test="${index.count %2 == 0}">
                <tr class="listEven">
              </c:when>
              <c:otherwise>
                <tr class="listOdd">
              </c:otherwise>
            </c:choose>
          
            <c:url var="viewUrl" value="/ep/micrositeTemplateView.do">
              <c:param name="micrositeTemplateId" value="${item.map.id}"/>
              <c:param name="instanceCount" value="${item.map.instanceCount}"/>
            </c:url>
            <td headers="Name">
              <a href='<c:out value="${viewUrl}"/>'>
                <c:out value="${item.map.name}"/>
              </a>
            </td>
          
            <td headers="Description"><c:out value="${item.map.description}"/></td>
            <td headers="InstanceCount"><c:out value="${item.map.instanceCount}"/></td>       
            <td headers="Actions">
              <a href='#' onclick="doMicrositeTemplateEditAction('<c:out value="${item.map.id}"/>', '<c:out value="${item.map.instanceCount}"/>');">
                <c:out value='${editImg}' escapeXml="false"/></a>
              <c:if test="${item.map.instanceCount==0}">                
                <a href='#' onclick="doMicrositeTemplateDeleteAction('<c:out value="${item.map.id}"/>');">
                  <c:out value='${deleteImg}' escapeXml="false"/></a>
              </c:if>             
            </td>
          
          </tr>
        </c:forEach>
      </c:when>
      <c:otherwise>
        <tr class="listOdd">
          <td align="center" colspan="6">
            <bean-el:message key="ep.microsite.template.noFound" bundle="ep.messages"/>
          </td>
        </tr>
      </c:otherwise>
      </c:choose>

    </table>

    <!-- pagination -->
    <c:if test="${not empty list}">
        <%@ include file="/mc/common/pager.jsp" %>
    </c:if>

    </td>
  </tr>
</table>
</html-el:form>

